<!-- 大底订购作业：蹇泽阳 -->
<template>
  <div class="app-container">
    <Find :OriginalFilter="{ static: true }" :formList="formList" @findClicked="findClicked" />
    <Find :OriginalFilter="{ static: true }" :formList="formList2" :searchImg="false" @findClicked="findClicked2" />
    <div class="flex mt10" style="width: 100%; background-color: white">
      <el-card shadow="never" :body-style="{ padding: '0px 10px 5px' }">
        <div slot="header" class="f16">
          <Find :OriginalFilter="{ static: true }" :formList="formList3" :searchImg="false" @findClicked="findClicked3" />
          <div style="font-weight: 600; margin-top: 10px">大底订购明细</div>
        </div>
        <Table
          :tableHeader="tableHeader"
          :tableData="tableData"
          selection
          class="mt10"
          :outTableHeight="200"
          :isLoading="isLoading"
          :summaryData="summaryData"
          summary
          @selectList="selectList1"
          :getTableList="getTableList"
          @inputChange="confirmChange"
          @currentRow="clickRow"
        />
      </el-card>
    </div>
    <el-card shadow="never" :body-style="{ padding: '5px' }">
      <PageModule :PageData="{ total, buttonS: true }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
    </el-card>

    <!-- 选指令（正单） -->
    <el-drawer v-model="dialogTableVisible2" :direction="'ttb'" size="small" :with-header="false">
      <el-card shadow="never" :body-style="{ padding: '11px 20px' }">
        <Find :OriginalFilter="{ static: true }" :formList="formList4" :searchImg="false" :FormClass="'addFind'" @findClicked="findClicked4" />
        <Table
          :tableHeader="tableHeader2"
          :tableData="tableData2"
          selection
          class="mt10"
          :outTableHeight="200"
          :isLoading="isLoading2"
          @selectList="selectList2"
        />
        <PageModule :PageData="{ total: total2, buttonS: true }" @pageSizeChange="handleSizeChange2" @pageChange="handleCurrentChange2" />
      </el-card>
    </el-drawer>
    <!-- 选指令（补单） -->
    <el-drawer v-model="dialogTableVisible3" :direction="'ttb'" size="small" :with-header="false">
      <el-card shadow="never" :body-style="{ padding: '11px 20px' }">
        <Find :OriginalFilter="{ static: true }" :formList="formList5" :searchImg="false" :FormClass="'addFind'" @findClicked="findClicked5" />
        <Table
          :tableHeader="tableHeader3"
          :tableData="tableData3"
          selection
          class="mt10"
          :outTableHeight="200"
          :isLoading="isLoading3"
          @selectList="selectList3"
        />
        <PageModule :PageData="{ total: total3, buttonS: true }" @pageSizeChange="handleSizeChange3" @pageChange="handleCurrentChange3" />
      </el-card>
    </el-drawer>
  </div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, watch } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'OutsoleOrdert'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import Find from '@/components/Find/index.vue'
import { selectList, selectSomeList } from '@/plugins/mixin'
import LoginWork from '@/utils/LoginWork'
import fileRequest from '@/utils/fileRequest'
import service from '@/utils/request'
import { ElMessage } from 'element-plus'
import { debounce } from 'lodash'
const dialogTableVisible2 = ref(false)
const dialogTableVisible3 = ref(false)
// 分页器
const total4 = ref(0)
const currentPage4 = ref(1)
const pageSize4 = ref(40)
const formList = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入货号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入底模号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入厂商',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入订购单号',
    inputValue: ''
  },
  {
    type: 'date',
    dateLabel: '订购日期',
    dateValue: ''
  },
  {
    type: 'checkbox',
    checkboxLabel: '未下单',
    checked: true
  },
  {
    type: 'checkbox',
    checkboxLabel: '已下单',
    checked: false
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '查询',
    bgColor: '#1890FF'
  }
]) as any
const formList2 = ref([
  {
    type: 'button',
    checkboxLabel: '选指令(正单)'
  },
  {
    type: 'button',
    checkboxLabel: '选指令(补单)'
  },
  {
    type: 'button',
    checkboxLabel: '生成物料编码'
  },
  {
    type: 'button',
    checkboxLabel: '置空物料编码'
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '厂商代码 厂商名称',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'dateSingle',
    dateValue: '',
    dateLabel: '交期'
  },
  {
    type: 'button',
    checkboxLabel: '形成订购单'
  },
  {
    type: 'button',
    checkboxLabel: '导出订购单'
  },
  {
    type: 'button',
    checkboxLabel: '置空订购信息'
  },
  {
    type: 'button',
    checkboxLabel: '打勾记录删除'
  },
  {
    type: 'button',
    checkboxLabel: '复制材料信息'
  }
]) as any
const mtlNo = ref('L501000')
const formList3 = ref<any>([
  // {
  //   type: 'select',
  //   selectValue: mtlNo.value,
  //   PageModule: true,
  //   changeFilterMethod: true,
  //   total: total4,
  //   handleSizeChange: (val: any) => {
  //     pageSize4.value = val
  //     getMtlNoSelect()
  //   },
  //   handleCurrentChange: (val: any) => {
  //     currentPage4.value = val
  //     getMtlNoSelect()
  //   },
  //   selectP: '物料编码',
  //   selectLabel: '',
  //   selectOptions: []
  // },
  {
    type: 'input',
    inputPlaceholder: '',
    inputLabel: '大底名称和颜色',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '',
    inputLabel: '备注信息',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '责任人',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '责任原因',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'button',
    checkboxLabel: '插入材料信息'
  }
])
const formList4 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入货号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '底模号',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '楦头号',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '生成订购资料'
  },
  {
    type: 'button',
    checkboxLabel: '返回'
  }
])
const formList5 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入货号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '底模号',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '楦头号',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '生成订购资料'
  },
  {
    type: 'button',
    checkboxLabel: '返回'
  }
])
const tableHeader = ref([
  {
    label: '类型',
    prop: 'purType',
    width: '70px',
    change: true
  },
  {
    label: '指令',
    prop: 'lotNo',
    width: '150px',
    change: true
  },
  {
    label: '货号',
    prop: 'style',
    width: '70px',
    change: true
  },
  {
    label: '品牌',
    prop: 'brand',
    width: '70px',
    change: true
  },
  {
    label: '颜色',
    prop: 'color',
    width: '100px',
    change: true
  },
  {
    label: '底模号',
    prop: 'moldNo',
    width: '100px',
    change: true
  },
  {
    label: '订单数',
    prop: 'orderQty',
    width: '50px',
    change: true
  },
  {
    label: '号码',
    prop: 'sizeNo',
    width: '50px',
    change: true
  },
  {
    label: '订购单号',
    prop: 'purNo',
    width: '140px',
    change: true
  },
  {
    label: '订购日期',
    prop: 'purDate',
    width: '75px',
    change: true
  },
  {
    label: '请购数',
    prop: 'purQty',
    width: '70px'
  },
  {
    label: '物料编码',
    prop: 'mtlNo',
    width: '100px',
    change: true
  },
  {
    label: '大底名称和颜色(双击调用信息到输入栏)',
    prop: 'mtlName',
    width: '330px',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    width: '50px',
    change: true
  },
  {
    label: '厂商',
    prop: 'vendorName',
    width: '70px',
    change: true
  },
  {
    label: '交期',
    prop: 'deliveryDate',
    width: '80px',
    change: true
  },
  {
    label: '备注',
    prop: 'remark',
    width: '120px',
    change: true
  },
  {
    label: '责任人',
    prop: 'dutyUser',
    width: '70px',
    change: true
  },
  {
    label: '责任原因',
    prop: 'dutyRek',
    width: '80px',
    change: true
  }
])
const tableHeader2 = ref([
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '纸板号',
    prop: 'shoeName'
  },
  {
    label: '工厂货号',
    prop: 'style'
  },
  {
    label: '品牌',
    prop: 'brand'
  },
  {
    label: '颜色',
    prop: 'color'
  },
  {
    label: '楦头',
    prop: 'lastNo'
  },
  {
    label: '大底',
    prop: 'moldNo'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '数量',
    prop: 'qty'
  }
])
const tableHeader3 = ref([
  {
    label: '指令号',
    prop: 'lotNo'
  },
  {
    label: '纸板号',
    prop: 'shoeName'
  },
  {
    label: '工厂货号',
    prop: 'style'
  },
  {
    label: '品牌',
    prop: 'brand'
  },
  {
    label: '颜色',
    prop: 'color'
  },
  {
    label: '楦头',
    prop: 'lastNo'
  },
  {
    label: '大底',
    prop: 'moldNo'
  },
  {
    label: '号码',
    prop: 'sizeNo'
  },
  {
    label: '数量',
    prop: 'qty'
  }
])
const getSelectList = async () => {
  await selectSomeList(formList2, () => service.get('/back/vendorMoldQuery'))
  await selectSomeList(formList2, () => service.get('/back/vendorMoldQuery'))
  await selectList(formList4, () => service.get('/back/order/allOrderCondition'))
  await selectList(formList5, () => service.get('/back/order/allOrderCondition'))
  // 插入责任人和责任原因
  await selectList(formList3, () => service.get('/back/duty/getDutyCondition'))
}

onMounted(() => {
  getSelectList()
  // getMtlNoSelect()
})

// 表一模块
const findClicked = (content: string) => {
  if (content === '置空') {
    formList.value.forEach((item: any) => {
      item.inputValue = ''
      item.selectValue = ''
      item.dateValue = ''
    })
  }
  if (content === '查询') {
    getTableList()
  }
}

const findClicked2 = async (content: string) => {
  if (content === '选指令(正单)') {
    dialogTableVisible2.value = true
    getTableList2()
  }
  if (content === '选指令(补单)') {
    dialogTableVisible3.value = true
    getTableList3()
  }
  if (content === '生成物料编码') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 1,
      list: selectedList1.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
  if (content === '置空物料编码') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 2,
      list: selectedList1.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
  if (content === '形成订购单') {
    let reg = formList2.value.find(
      (item: any) => item.type === 'select' && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '厂商代码 厂商名称'
    )?.selectValue
    let reg2 = formList2.value.find(
      (item: any) => item.dateLabel && Jzhcn.Find[item.dateLabel.split('.')[1] as keyof typeof Jzhcn.Find] === '交期'
    )?.dateValue
    if (!reg) JMessage.warning('厂商代码 厂商名称 不能为空')
    if (!reg2) JMessage.warning('交期 不能为空')
    if (!reg || !reg2) return
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 3,
      deliveryDate: reg2,
      list: selectedList1.value,
      vendorName: reg.split(' ')[1],
      vendorNo: reg.split(' ')[0]
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      formList.value.find((item: any) => item.type === 'checkbox' && i18n.global.t(item.checkboxLabel) === '已下单').checked = true
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
  if (content === '导出订购单') {
    if (!currentClickRow.value.purNo) {
      JMessage.warning('没有订购单号')
      return
    }
    const res = (await fileRequest.get(`/material/downloadSoleOrder?slipNo=${currentClickRow.value.purNo}`)) as any
    const link = document.createElement('a') // 利用a标签自定义下载文件名
    let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
    link.style.display = 'none'
    //设置连接
    link.href = window.URL.createObjectURL(blob)
    const FileName = decodeURI(res.headers['content-disposition'].split(`utf-8''`)[1])
    link.download = FileName //自定义文件名字
    document.body.appendChild(link)
    //模拟点击事件
    link.click()
    document.body.removeChild(link)
  }
  if (content === '置空订购信息') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 4,
      list: selectedList1.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
  if (content === '打勾记录删除') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 5,
      list: selectedList1.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
  if (content === '复制材料信息') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/operateSole', {
      choose: 6,
      list: selectedList1.value
    })
    if (res.code === 200) {
      JMessage.success('复制材料信息成功')
    } else {
      JMessage.warning(res.message)
    }
    getTableList()
  }
}
// 获取物料编码下拉框数据
const getMtlNoSelect = async () => {
  let mtl = formList3.value.find(
    (item: any) => item.type === 'select' && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '物料编码'
  ) as any
  mtl.selectOptions.splice(0)
  const res = await service.get<any, any>('/back/getMtlName3', {
    params: {
      mtlNo: mtlNo.value,
      pageNum: currentPage4.value,
      pageSize: pageSize4.value
    }
  })
  if (mtl && res) {
    res.list.forEach((item: any, index: any) => {
      if (item === null) return
      mtl.selectOptions?.push({
        optionKey: index,
        optionValue: `${item.mtlColor}  ${item.mtlName}  ${item.mtlSpec}  ${item.mtlUnit}  ${item.mtlNo}`,
        optionLabel: `${item.mtlNo}`,
        LeftLabel: `${item.mtlNo}`,
        RightLabel: `${item.mtlColor}  ${item.mtlName}  ${item.mtlSpec}  ${item.mtlUnit}`
      })
    })
    total4.value = res.total
  }
}
const findClicked3 = async (content: string) => {
  if (content === '插入材料信息') {
    if (selectedList1.value.length === 0) {
      JMessage.warning('请勾选大底订购明细')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/insertIntoOther', {
      dutyPerson: formList3.value.find(
        (item: any) => item.type === 'select' && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '责任人'
      ).selectValue,
      dutyRek: formList3.value.find(
        (item: any) => item.type === 'select' && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '责任原因'
      ).selectValue,
      list: selectedList1.value,
      mtlName: formList3.value[0].inputValue,
      // mtlNo: formList3.value[0].selectValue.split('  ')[4],
      remark: formList3.value[1].inputValue
    })
    if (res.code === 200) {
      JMessage.success(res.message)
      getTableList()
    } else {
      JMessage.warning(res.message)
    }
  }
}
// watch(formList3.value[0], () => {
//   formList3.value[1].inputValue = formList3.value[0].selectValue.split('  ')[1]
// })

const selectedList1 = ref([])
const selectList1 = (list: any) => {
  selectedList1.value = list
}
const selectedList2 = ref([])
const selectList2 = (list: any) => {
  selectedList2.value = list
}
const findClicked4 = async (content: string) => {
  if (content === '置空') {
    formList4.value.forEach((item: any) => {
      item.inputValue = ''
      item.selectValue = ''
      item.dateValue = ''
    })
  }
  if (content === '生成订购资料') {
    if (selectedList2.value.length === 0) {
      JMessage.warning('请勾选订购资料')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/createPcMtlMoldLot', {
      choose: 1,
      list: selectedList2.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
    } else {
      JMessage.warning(res.message)
    }
    getTableList()
    getTableList2()
  }
  if (content === '返回') {
    dialogTableVisible2.value = false
  }
}
const tableData = ref([])
const isLoading = ref(true)
// 总计
interface summaryDataType {
  index: number
  num: number | undefined
}
const summaryData = ref<summaryDataType[]>([
  {
    index: 11,
    num: 0
  },
  {
    index: 7,
    num: 0
  }
])
// 分页器
const currentPage = ref(1)
const pageSize = ref(40)
const total = ref(0)
const handleSizeChange = (val: number) => {
  pageSize.value = val
  getTableList()
}
const handleCurrentChange = (val: number) => {
  currentPage.value = val
  getTableList()
}
// 表格计算函数
const cfmFlag = () => {
  const Unaudited = formList.value.find((item: any) => item.type === 'checkbox' && i18n.global.t(item.checkboxLabel) === '已下单')
  const Audited = formList.value.find((item: any) => item.type === 'checkbox' && i18n.global.t(item.checkboxLabel) === '未下单')
  if (!Unaudited || !Audited) return
  if (Unaudited.checked && Audited.checked) {
    return ''
  } else if (Unaudited.checked) {
    return '2'
  } else if (Audited.checked) {
    return '1'
  } else {
    ElMessage('必须至少选择一项')
    Unaudited.checked = true
    Audited.checked = true
    return ''
  }
}
// 获取表数据
const getTableList = debounce(async () => {
  isLoading.value = true
  let tableDataList = await service.post<any, any>('/material/mold/getOutsoleOrderDetail', {
    lotNo: formList.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入指令号'
    )?.inputValue,
    moldNo: formList.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入底模'
    )?.inputValue,
    purEndDate: formList.value.find(
      (item: any) => item.dateLabel && Jzhcn.Find[item.dateLabel.split('.')[1] as keyof typeof Jzhcn.Find] === '订购日期'
    )?.dateValue?.[1],
    purNo: formList.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入订购单号'
    )?.inputValue,
    purStartDate: formList.value.find(
      (item: any) => item.dateLabel && Jzhcn.Find[item.dateLabel.split('.')[1] as keyof typeof Jzhcn.Find] === '订购日期'
    )?.dateValue?.[0],
    style: formList.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入货号'
    )?.inputValue,
    vendorName: formList.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入厂商'
    )?.inputValue,
    pageNum: currentPage.value,
    pageSize: pageSize.value,
    order: cfmFlag() //	有无欠数(Y/N)	string	body	true
  })
  isLoading.value = false

  tableData.value = tableDataList.list.map((item: any) => {
    item.change = 'Y'
    item.disableConfirm = true
    return item
  })
  total.value = tableDataList.total
  // currentRow()
  summaryData.value[0].num = tableDataList.purQtyTotal
  summaryData.value[1].num = tableDataList.qtyTotal
  clickRow()
}, 500)
onMounted(() => {
  getTableList()
})
watch(
  () =>
    formList.value.map((item: any) => {
      item.selectValue, item.inputValue, item.dateValue, item.checked
    }),
  () => {
    getTableList()
  }
)

// 表二
const selectedList3 = ref([])
const selectList3 = (list: any) => {
  selectedList3.value = list
}
const findClicked5 = async (content: string) => {
  if (content === '置空') {
    formList5.value.forEach((item: any) => {
      item.inputValue = ''
      item.selectValue = ''
      item.dateValue = ''
    })
  }
  if (content === '生成订购资料') {
    if (selectedList3.value.length === 0) {
      JMessage.warning('请勾选订购资料')
      return
    }
    let res = await LoginWork.post<any, any>('/material/mold/createPcMtlMoldLot', {
      choose: 1,
      list: selectedList3.value
    })
    if (res.code === 200) {
      JMessage.success(res.message)
    } else {
      JMessage.warning(res.message)
    }
    getTableList()
    getTableList3()
  }
  if (content === '返回') {
    dialogTableVisible3.value = false
  }
}
const tableData2 = ref([])
// 分页器
const currentPage2 = ref(1)
const pageSize2 = ref(40)
const total2 = ref(0)
const handleSizeChange2 = (val: number) => {
  pageSize2.value = val
  getTableList2()
}
const handleCurrentChange2 = (val: number) => {
  currentPage2.value = val
  getTableList2()
}
const isLoading2 = ref(true)
const getTableList2 = debounce(async () => {
  isLoading2.value = true
  let tableDataList = await service.post<any, any>('/material/mold/getPcMtlMoldLot', {
    lastNo: formList4.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入楦头号'
    )?.inputValue,
    lotNo: formList4.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入指令'
    )?.inputValue,
    moldNo: formList4.value.find((item: any) => item.selectP && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '底模号')
      ?.selectValue,
    pageNum: currentPage2.value,
    pageSize: pageSize2.value,
    style: formList4.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入货号'
    )?.inputValue,
    choose: 1
  })
  isLoading2.value = false
  tableData2.value = tableDataList.list
  total2.value = tableDataList.total
}, 500)
watch(
  () =>
    formList4.value.map((item: any) => {
      item.selectValue, item.inputValue, item.dateValue, item.checked
    }),
  () => {
    getTableList2()
  }
)

// 表三
const tableData3 = ref([])
// 分页器
const currentPage3 = ref(1)
const pageSize3 = ref(40)
const total3 = ref(0)
const handleSizeChange3 = (val: number) => {
  pageSize3.value = val
  getTableList3()
}
const handleCurrentChange3 = (val: number) => {
  currentPage3.value = val
  getTableList3()
}
const isLoading3 = ref(true)
const getTableList3 = debounce(async () => {
  isLoading3.value = true
  let tableDataList = await service.post<any, any>('/material/mold/getPcMtlMoldLot', {
    lastNo: formList5.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入楦头号'
    )?.inputValue,
    lotNo: formList5.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入指令'
    )?.inputValue,
    moldNo: formList5.value.find((item: any) => item.selectP && Jzhcn.Find[item.selectP.split('.')[1] as keyof typeof Jzhcn.Find] === '底模号')
      ?.selectValue,
    pageNum: currentPage3.value,
    pageSize: pageSize3.value,
    style: formList5.value.find(
      (item: any) => item.inputPlaceholder && Jzhcn.Find[item.inputPlaceholder.split('.')[1] as keyof typeof Jzhcn.Find] === '请输入货号'
    )?.inputValue,
    choose: 2
  })
  isLoading3.value = false
  tableData3.value = tableDataList.list
  total3.value = tableDataList.total
}, 500)
watch(
  () =>
    formList5.value.map((item: any) => {
      item.selectValue, item.inputValue, item.dateValue, item.checked
    }),
  () => {
    getTableList3()
  }
)

const filterMethod = (val: any, selectOptions: any, copyOptions: any) => {
  mtlNo.value = val
  // getMtlNoSelect()
}

// 修改后点击确定按钮
const confirmChange = async (row: any, fn: any) => {
  await service.post('/material/mold/operateSole', { choose: 7, list: [row, currentClickRow.value] })
  fn()
  JMessage.success('修改成功')
}
const currentClickRow = ref()
const clickRow = (row: any = tableData.value[0]) => {
  currentClickRow.value = JSON.parse(JSON.stringify(row))
}
</script>

<style lang="less" scoped>
:deep(.el-form-item:nth-child(5)) {
  .el-select {
    width: 150px;
    height: 28px;
  }
}
</style>
